package com.itheima.nio.buffer.demo01;

import java.nio.ByteBuffer;

public class ByteBufferDemo01 {

    public static void main(String[] args) {

        ByteBuffer byteBuffer = ByteBuffer.allocate(10);
        System.out.println(byteBuffer);

        String s = "lanwangji";
        byte[] bytes = s.getBytes();
        ByteBuffer byteBuffer1 = ByteBuffer.wrap(bytes);
        System.out.println(byteBuffer1);

        System.out.println(byteBuffer.capacity());
        System.out.println(byteBuffer.limit());
        System.out.println(byteBuffer.position());
        System.out.println(byteBuffer.remaining());
        System.out.println(byteBuffer.hasRemaining());

        System.out.println(byteBuffer.limit(8));
        System.out.println(byteBuffer.position(3));
    }
}
